home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / etc / bash_completion.d / vncviewer < prev   
Text File  |  2009-04-02  |  3KB  |  127 lines

  1. # -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
  2. # ex: ts=8 sw=8 noet filetype=sh
  3. #
  4. # bash completion for vncviewer
  5.  
  6.  
  7. _vncviewer_bootstrap() {
  8.     local fname
  9.     case "$(_realcommand vncviewer)" in
  10.         # If `vncviewer' not installed, default file-dir completion 
  11.         '') _filedir `_get_cword` ;;
  12.         *xvnc4viewer)      fname=_xvnc4viewer    ;;
  13.         *tightvncviewer|*) fname=_tightvncviewer ;;
  14.     esac
  15.     if [ $fname ]; then
  16.         # Install real completion for subsequent completions
  17.         complete -F $fname vncviewer
  18.         $fname  # Generate completions once for now
  19.         unset -f _vncviewer_bootstrap
  20.     fi
  21. } &&
  22. complete -F _vncviewer_bootstrap vncviewer
  23.  
  24.  
  25. _tightvncviewer()
  26. {
  27.     local cur prev
  28.  
  29.     COMPREPLY=()
  30.     cur=`_get_cword`
  31.     prev=${COMP_WORDS[COMP_CWORD-1]}
  32.  
  33.     case $prev in
  34.         -passwd)
  35.             _filedir
  36.             return 0
  37.             ;;
  38.         -encodings)
  39.             COMPREPLY=( $( compgen -W 'copyrect tight hextile zlib \
  40.                 corre rre raw' -- $cur ) )
  41.             return 0
  42.             ;;
  43.         -via)
  44.             _known_hosts
  45.             return 0
  46.             ;;
  47.     esac
  48.  
  49.  
  50.     if [[ "$cur" == -* ]]; then
  51.         COMPREPLY=( $( compgen -W '-help -listen -via -shared -noshared\
  52.             -viewonly -fullscreen -noraiseonbeep -passwd -encodings\
  53.             -bgr233 -owncmap -truecolour -truecolor -depth \
  54.             -compresslevel -quality -nojpeg -nocursorshape \
  55.             -x11cursor' -- $cur ) )
  56.     else
  57.         _known_hosts
  58.     fi
  59. } &&
  60. complete -F _tightvncviewer tightvncviewer
  61.  
  62.  
  63. # NOTE: - VNC Viewer options are case-insensivite.  Preferred case is taken from -help.
  64. #       - Both single dash (-) and double dash (--) are allowed as option prefix
  65. _xvnc4viewer()
  66. {
  67.     local cur prev
  68.  
  69.     COMPREPLY=()
  70.     cur=`_get_cword`
  71.     prev=${COMP_WORDS[COMP_CWORD-1]}
  72.  
  73.     # Convert double dash to single dash
  74.     case ${prev/#--/-} in
  75.         # -passwd, -PasswordFile
  76.         -[pP][aA][sS][sS][wW][dD]|-[pP][aA][sS][sS][wW][oO][rR][dD][fF][iI][lL][eE])
  77.             _filedir
  78.             return 0
  79.             ;;
  80.         # -PreferredEncoding
  81.         -[pP][rR][eE][fF][eE][rR][rR][eE][dD][eE][nN][cC][oO][dD][iI][nN][gG])
  82.             COMPREPLY=( $( compgen -W 'zrle hextile raw' -- $cur ) )
  83.             return 0
  84.             ;;
  85.         # -via
  86.         -[vV][iI][aA])
  87.             _known_hosts
  88.             return 0
  89.             ;;
  90.     esac
  91.  
  92.     if [[ "$cur" == -* || "$cur" == --* ]]; then
  93.         # Default to vncviewer camelcase options, see `vncviewer -help'
  94.         local dash options=( \
  95.             AcceptClipboard AutoSelect DebugDelay display \
  96.             DotWhenNoCursor FullColor FullColour FullScreen \
  97.             geometry help listen Log \
  98.             LowColourLevel MenuKey name Parent \
  99.             passwd PasswordFile PointerEventInterval PreferredEncoding \
  100.             SendClipboard SendPrimary Shared UseLocalCursor \
  101.             via ViewOnly WMDecorationHeight WMDecorationWidth \
  102.             ZlibLevel \
  103.         )
  104.         [[ "$cur" == --* ]] && dash=-- || dash=-
  105.         # Is a `nocasematch' variable available (bash > v3.1)?
  106.         if shopt nocasematch 2> /dev/null | grep -q ^nocasematch; then
  107.             # Variable `nocasematch' is available
  108.             # Use vncviewer camelcase options
  109.             local option oldNoCaseMatch=$(shopt -p nocasematch)
  110.             shopt -s nocasematch
  111.             COMPREPLY=( $( for option in "${options[@]}"; do
  112.                 [[ $dash$option == "$cur"* ]] && echo $dash$option
  113.             done ) )
  114.             eval "$oldNoCaseMatch" 2> /dev/null
  115.         else
  116.             # Variable 'nocasematch' isn't available;
  117.             # Convert completions to lowercase
  118.             COMPREPLY=( $( compgen -W "$(
  119.                 echo ${options[@]/#/$dash} | tr [:upper:] [:lower:]    
  120.             )" -- "$(echo "$cur" | tr [:upper:] [:lower:])" ) )
  121.         fi
  122.     else
  123.         _known_hosts
  124.     fi
  125. } &&
  126. complete -F _xvnc4viewer xvnc4viewer
  127.